<template>
  <div>

    <p slot="header" class="modal_head">
      <span v-show="modalTitle != 4">{{
        this.modalTitle == 9
          ? "同屏邀请"
          : this.modalTitle == 8
            ? "分享文章"
            : this.modalTitle == 7
              ? "分享文件"
              : modalTitle == 0
                ? "创建聊天"
                : modalTitle == 1
                  ? "发送广播"
                  : modalTitle == 2
                    ? "转发消息"
                    : modalTitle == 3
                      ? "转发文件"
                      : modalTitle == 4
                        ? "添加成员"
                        : modalTitle == 5
                          ? "添加参与人"
                          : "分享入群"
      }}
      </span>
    </p>
    <div class="modal_main">
      <div class="modal_left_w">
        <div class="modal_l_btn_w">
          <div class="m_l_btn_m">
            <Button class="my_btn">{{ myInfo.name }}</Button>
            <Button class="ot_btn" v-for="(item, index) in checkPersonArray" :key="index">
              <span>{{ item.name }}</span>
              <span class="modalPersonButtonClose" @click="checkPersonDelete(item, index)"></span>
            </Button>
          </div>
        </div>
        <div v-show="modalTitle == 0">
          <div>群名称 <span class="group_n_t">-必填</span></div>
          <input type="text" placeholder="取个群名称方便后续搜索" class="homeModalName" v-model="modalNameValue" />
        </div>
        <div v-show="modalTitle == 2">
          <input type="text" placeholder="给对方留言" class="homeModalName" v-model="forwardMsg" />
        </div>
        <div class="modal_b_w">
          <Button type="info" :disabled="addUserDisabled" @click.native="determine">确定</Button>
          <Button class="close_btn" @click="modalFirstCancel">取消</Button>
          <!-- ({{personCount}}/1000) -->
        </div>
      </div>
      <div class="modal_right_w">
        <div class="modal_search_box">
          <input class="moadl_s_val" type="text" placeholder="搜索名字、手机号、账号" v-model="modalSearchValue"
            @keyup.enter="searchMemberEnter" tabindex="1" />
          <ul class="modalSearchResultUlStyle"
            v-show="modalSearchResult != '' && modalSearchResult.length > 0 && modalSearchValue != ''" tabindex="2">
            <li class="modalSearchList" v-for="(item, index) in modalSearchResult" @click="setStruChoose(item, index)"
              :key="index">
              {{ item.name }} {{ item.account ? item.account : '' }} ({{
                item.isGroup == 1 ? "群" : item.departmentname
              }}{{ item.jobtitle ? "" : item.jobtitle }})
            </li>
            <span class="modalSearchMore" v-if="
              modalSearchResult.length >=
              parseInt(searchSize) + parseInt(newGroupList.length) &&
              moreSearchShow
            " @click="more_search(99)">{{ "查找更多" }}</span>
          </ul>
        </div>
        <!--  modalTitle != 8 ? true :  item.id == 7 ? false : true  && -->
        <ul class="homeContact" v-if="modalCheckArray.show == false">
          <li v-for="(item, index) in modalFirstList" :key="'moadal_' + index" @click="setModalCheckArray(item, index)"
            v-show="
              !(modalTitle == 8 && item.id == 7) &&
              ((item.id == 7 && (modalTitle == 2 || modalTitle == 3)) ||
                (modalTitle == 9 && item.id != 5 && item.id != 6) ||
                modalTitle == 2 ||
                modalTitle == 6 ||
                ((modalTitle == 7 || modalTitle == 8) &&
                  item.id != 5 &&
                  item.id != 6) ||
                modalTitle == 3 ||
                (modalTitle == 5 && item.id != 5 && item.id != 6) ||
                (modalTitle == 1 && item.id == 3) ||
                (modalTitle == 0 && item.id != 5 && item.id != 6 && item.id != 7) ||
                (modalTitle == 4 && item.id != 5 && item.id != 6))
            ">
            <img draggable="false" :src="item.url" />
            <span>{{ item.title }}</span>
          </li>
        </ul>
        <div v-if="modalCheckArray.show != false" class="modal_arr_box">
          <div class="modal_r_s_t">
            <span class="modalBack" @click="setModalCheckArray(null)"></span>
            <h3>按{{ modalCheckArray.title }}查找</h3>
          </div>
          <div v-if="modalCheckArray.id == 4" class="modal_firend_box">
            <!-- <div class="selectAll" @click.stop='selectAll(4)'>
								<span class='checkSpan' :class='{chooseSpan:organizationChoose}'></span>
								<div>全选</div>
							</div> -->
            <ul>
              <li v-for="(item, index) in modalCheckArray.list" :key="index">
                <ul>
                  <li v-for="(temp, count) in item.USER" class="modalFirendList" @click="setChoose(temp, count)"
                    :key="count">
                    <span class="checkSpan" :class="{ chooseSpan: temp.isChoose }"></span>
                    <img draggable="false" :src="
                      !$isNull(temp.HEAD)
                        ? `${$store.state.headPathUrl}${temp.ID}${temp.HEAD}.PNG`
                        : `static/image/home/person_${(temp.GENDER || temp.gender || temp.SEX) == 1
                          ? 1
                          : 2
                        }.png`
                    " class="person_img" :onerror="defaultImg" />
                    <span>{{ temp.NAME }}</span>
                  </li>
                </ul>
              </li>
            </ul>
          </div>
          <div v-if="modalCheckArray.id == 5" class="modal_firend_box">
            <div class="selectAll" @click.stop="selectAll(5)">
              <span class="checkSpan" :class="{ chooseSpan: organizationChoose }"></span>
              <div>全选</div>
            </div>
            <ul>
              <li v-for="(temp, count) in modalCheckArray.list3" class="modalFirendList"
                @click="setLastChoose(temp, count)" :key="count">
                <span class="checkSpan" :class="{ chooseSpan: temp.isChoose }"></span>
                <img draggable="false" :src="
                  temp.isGroup == '1'
                    ? 'static/image/home/chat/session_group.png'
                    : !$isNull(temp.head)
                      ? `${$store.state.headPathUrl}${temp.id}${temp.head}.PNG`
                      : `static/image/home/person_${temp.gender == 2 ? 2 : 1
                      }.png`
                " class="person_img" :onerror="defaultImg" />
                <span class="groupNameList">{{ temp.name }}</span>
              </li>
            </ul>
          </div>
          <div v-if="modalCheckArray.id == 3" class="modal_nav_box">
            <div class="modal_nav">
              <div class="modal_nav_item" v-for="(item, index) in modalCheckArray.navList" :key="index">
                <span v-if="index != 0" class="m_v_i_f">/</span>
                <span class="navTitle" v-if="index != modalCheckArray.navList.length - 1"
                  @click="setModalIndex(item, index)">{{ item.value }}</span>
                <span v-else class="m_n_v">{{ item.value }}</span>
              </div>
            </div>
            <div class="selectAll" @click.stop="selectAll(3)" v-show="
              selectAllShow(
                modalCheckArray.list2[this.modalCheckArray.index]
              )
            ">
              <span class="checkSpan" :class="{ chooseSpan: organizationChoose }"></span>
              <div>全选</div>
            </div>
            <ul class="modal_stru_box">
              <li v-for="(item, index) in modalCheckArray.list2[
                this.modalCheckArray.index
              ]" class="modalFirendList" @click="modalGetStru(item, index)" :key="index">
                <span class="checkSpan" v-if="
                  (modalTitle != 5 && modalTitle != 6 && modalTitle != 2) ||
                  ((modalTitle == 5 ||
                    modalTitle == 6 ||
                    modalTitle == 2) &&
                    !item.FID)
                " :class="{
  chooseSpan: item.isChoose || item.NO == myInfo.id,
}" @click.stop="setStruChoose(item, index)"></span>
                <img draggable="false" :src="
                  item.FID
                    ? 'static/image/home/contact/next.png'
                    : !$isNull(item.HEAD)
                      ? `${$store.state.headPathUrl}${item.ID}${item.HEAD}.PNG`
                      : `static/image/home/person_${(item.GENDER || item.gender || item.SEX) == 1
                        ? 1
                        : 2
                      }.png`
                " class="stru_icon" :class="{ fidNextImg: item.FID }" :onerror="defaultImg" />
                <span>{{ item.LEABLE }}</span>
              </li>
            </ul>
          </div>
          <div v-if="modalCheckArray.id == 6" class="modal_group_box">
            <div class="selectAll" @click.stop="selectAll(6)">
              <span class="checkSpan" :class="{ chooseSpan: organizationChoose }"></span>
              <div>全选</div>
            </div>
            <ul>
              <li v-for="(temp, count) in modalCheckArray.list4" class="modalFirendList"
                @click="setLastChoose(temp, count)" :key="count">
                <span class="checkSpan" :class="{ chooseSpan: temp.isChoose }"></span>
                <img draggable="false" src="static/image/home/chat/session_group.png" class="person_img" />
                <span class="groupNameList">{{ temp.name }}</span>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
        
  </div>
</template>
           
<script>
import {
  addGroup,
  getGroupPeople,
  getGroup,
  getUserListInfoSim,
  addGroupMembers,
  article_axios,
} from "../../api/home";
import tools from "@/utils/tools";
export default {
  data() {
    return {
      chuanshu:[],
      organizationChoose: false,
      newGroupList: [], //群搜索结果
      modalSearchResult: [],
      newModalSearchValue: "", //创建聊天搜索值
      moreSearchShow: true, // 新增组织架构搜索显示更多字段
      searchPage: 1,
      searchSize: 3,
      modalSearchValueFlag: null, //聊天搜索值防抖
      modalSearchValue: "",
      forwardMsg: "",
      modalNameValue: "",
    };
  },
  watch: {
    modalSearchValue(newVal, oldVal) {
      //zk1228标识，关键字改变时触发修改

      if (this.modalSearchValue != "" && newVal != oldVal) {
        if (this.modalSearchValueFlag) {
          window.clearTimeout(this.modalSearchValueFlag);
        }
        this.modalSearchValueFlag = setTimeout(() => {
          // 2022/5/30 zc修改 再判断避免为空时进入搜索而添加
          if (this.modalSearchValue != "") {
            this.searchMemberEnter();
          }
        }, 800);
      }
    },
  },
  props: [
    "modalTitle",
    "checkPersonArray",
    "myInfo",
    "addUserDisabled",
    "personalStatus",
    "myInfo",
    "toInfo",
    "modalFirstList",
    "modalCheckArray",
    "modalFirst",
    "participant",
    "isShare",
    "shareChoosed",
    "shareInfo",
    "ws",
    "shareFileArr",
    // "modalSearchResult",
    "isMultiSelect",
    "isToForwardingLocal",
    "chatChooseList",
    "toForwardingLocal",
    // "searchSize",
    // "newGroupList",
    "group_detail",
    // "organizationChoose",
    "friendsGroup",
    "defaultImg",
    "groupList",
    "sqlTable",
    "sessionList",
    "forwardingList",
    "screenFlag",
    "screenPersonList",
  ],
  methods: {
    //设置选中|取消 id、数组、结果
    setInitChoose(id, result) {
      if (this.modalCheckArray.list) {
        for (let i = 0; i < this.modalCheckArray.list.length; i++) {
          for (let j = 0; j < this.modalCheckArray.list[i].USER.length; j++) {
            if (this.modalCheckArray.list[i].USER[j].ID == id) {
              this.$set(
                this.modalCheckArray.list[i].USER[j],
                "isChoose",
                result
              );
            }
          }
        }
      }
      if (this.modalCheckArray.list2) {
        for (let i in this.modalCheckArray.list2) {
          for (let j = 0; j < this.modalCheckArray.list2[i].length; j++) {
            if (
              this.modalCheckArray.list2[i][j].FID == id ||
              this.modalCheckArray.list2[i][j].NO == id
            ) {
              this.$set(this.modalCheckArray.list2[i][j], "isChoose", result);
            }
          }
        }
      }
      if (this.modalCheckArray.list3) {
        for (let i = 0; i < this.modalCheckArray.list3.length; i++) {
          if (this.modalCheckArray.list3[i].id == id) {
            this.$set(this.modalCheckArray.list3[i], "isChoose", result);
          }
        }
      }
      if (this.modalCheckArray.list4) {
        for (let i = 0; i < this.modalCheckArray.list4.length; i++) {
          if (this.modalCheckArray.list4[i].id == id) {
            this.$set(this.modalCheckArray.list4[i], "isChoose", result);
          }
        }
      }
    },
    //建群、发送广播、转发左侧列表删除成员
    checkPersonDelete(item, index) {
      this.$emit("checkPersonArrayPush", index, 3);
      //   this.checkPersonArray.splice(index, 1);
      this.setInitChoose(item.id, false);
      // zk0601新增,删除某项时修改全选状态
      let idx = this.modalCheckArray.index;
      let idList = [];
      if (this.modalCheckArray.list2) {
        idList = []; //使用前清空,防止上一次结果的影响
        for (let i in this.modalCheckArray.list2[idx]) {
          let id =
            this.modalCheckArray.list2[idx][i].id ||
            this.modalCheckArray.list2[idx][i].ID;
          idList.push(id);
        }
      }
      if (idList.indexOf(item.id) != -1) {
        //删除的那一项是当前激活的组织架构中的某一项,全选置非
        this.organizationChoose = false;
      }
    },
    setSelectAll(arr) {
      this.organizationChoose = true;
      let list = arr || [];
      for (let i = 0; i < list.length; i++) {
        if (list[i].isChoose != true) {
          this.organizationChoose = false;
        }
      }
    },
    //建群、发送广播、转发右侧导航点击跳转
    setModalIndex(item, index) {
      this.modalCheckArray.index = item.title;
      console.log("转发右侧导航点击跳转", this.modalCheckArray.index);
      this.organizationChoose = true;
      // 分享群过滤掉已再群里的成员(组织架构)
      if (this.isShare) {
        this.modalCheckArray.list2[this.modalCheckArray.index] =
          this.modalCheckArray.list2[this.modalCheckArray.index].filter(
            (item) =>
              this.shareChoosed.indexOf(item.ID || item.id || item.NO) == -1
          );
      }
      this.setSelectAll(this.modalCheckArray.list2[this.modalCheckArray.index]);
      this.modalCheckArray.navList = this.modalCheckArray.navList.splice(
        0,
        index + 1
      );
    },
    selectAllFn(arr) {
      let list = arr || [];
      let count = 0;
      for (let i = 0; i < list.length; i++) {
        if (
          !(
            list[i].NO == this.myInfo.id ||
            list[i].id == this.myInfo.id ||
            list[i].FID == this.myInfo.id
          )
        ) {
          if (this.modalTitle != 5 && this.modalTitle != 2) {
            if (list[i].isChoose && this.organizationChoose) {
              this.$emit(
                "delCheckPerson",
                list[i].NO || list[i].FID || list[i].id
              );
              //   this.delCheckPerson(list[i].NO || list[i].FID || list[i].id);
            }
            this.$set(list[i], "isChoose", this.organizationChoose);
            if (this.organizationChoose) {
              list[i].id = list[i].NO || list[i].FID || list[i].id;
              list[i].name = list[i].LEABLE || list[i].name;
              this.checkPersonArray.push(list[i]);
            } else {
              this.$emit(
                "delCheckPerson",
                list[i].NO || list[i].FID || list[i].id
              );
              //   this.delCheckPerson(list[i].NO || list[i].FID || list[i].id);
            }
          } else {
            if (list[i].isChoose && this.organizationChoose) {
              this.$emit(
                "delCheckPerson",
                list[i].NO || list[i].FID || list[i].id
              );
              //   this.delCheckPerson(list[i].NO || list[i].FID || list[i].id);
            }
            if (!list[i].FID) {
              this.$set(list[i], "isChoose", this.organizationChoose);
              if (this.organizationChoose) {
                list[i].id = list[i].NO || list[i].FID || list[i].id;
                list[i].name = list[i].LEABLE || list[i].name;
                this.checkPersonArray.push(list[i]);
              } else {
                this.$emit(
                  "delCheckPerson",
                  list[i].NO || list[i].FID || list[i].id
                );
                // this.delCheckPerson(list[i].NO || list[i].FID || list[i].id);
              }
            }
          }
        }
      }
    },
    selectAll(index) {
      //   this.$emit("update:organizationChoose", !this.organizationChoose);
      this.organizationChoose = !this.organizationChoose;
      if (index == 3) {
        this.selectAllFn(
          this.modalCheckArray.list2[this.modalCheckArray.index]
        );
      } else if (index == 4) {
        for (let k in this.modalCheckArray.list) {
          this.selectAllFn(this.modalCheckArray.list[k]);
        }
      } else if (index == 5) {
        this.selectAllFn(this.modalCheckArray.list3);
      } else if (index == 6) {
        this.selectAllFn(this.modalCheckArray.list4);
      }
    },
    //组织架构选择成员
    setStruChoose(item, index) {
      console.log("进入点击事件0601"); //zk0601标注,组织架构勾选事件
      if (
        item.NO == this.myInfo.id ||
        item.id == this.myInfo.id ||
        item.FID == this.myInfo.id
      ) {
        this.$Message.destroy();
        this.$Message.warning({
          content: "不能选择自己",
          duration: 0.8,
        });
        return;
      }
      // 新增添加群成员 已再群里的成员禁止切换选中状态
      if (this.modalTitle == 4) {
        let arr =
          this.group_detail.users.filter(
            (value) => item.NO == (value.id || value.ID)
          ) || [];
        if (arr.length > 0) return;
        //新增添加群成员过滤已存在当前群的成员
        let list =
          this.group_detail.users.filter(
            (temp) =>
              (item.ID || item.id || item.NO) == (temp.id || temp.ID || temp.NO)
          ) || [];
        if (list.length > 0) {
          this.$Message.warning("人员已存在此群中");
          return;
        }
      }
      // 分享群过滤掉已再群里的成员(组织架构)
      if (
        this.isShare &&
        this.shareChoosed.indexOf(item.ID || item.id || item.NO) != -1
      ) {
        this.$Message.warning("人员已存在此群中");
        return;
      }
      let result = !item.isChoose;
      this.$set(item, "isChoose", result);
      if (result) {
        item.id = item.NO || item.FID || item.id || item.ID;
        item.name = item.LEABLE || item.name || item.NAME;
        this.$emit("checkPersonArrayPush", item, 1);
        // this.checkPersonArray.push(item);
        // this.checkPersonArray = this.$deWeight(this.checkPersonArray.push(item));

        // zk0601新增,全选状态调整
        let idList = [];
        for (let i in this.checkPersonArray) {
          let id = this.checkPersonArray[i].id || this.checkPersonArray[i].ID;
          idList.push(id);
        }
        let idx = this.modalCheckArray.index;
        if (this.modalCheckArray.list2) {
          console.log(this.modalCheckArray, "全部");
          let flag = true;
          for (let i in this.modalCheckArray.list2[idx]) {
            let id =
              this.modalCheckArray.list2[idx][i].id ||
              this.modalCheckArray.list2[idx][i].ID;
            if (idList.indexOf(id) == -1) {
              flag = false;
            }
          }
          //   this.$emit("update:organizationChoose", flag);
          this.organizationChoose = flag;
        }
      } else {
        this.$emit("delCheckPerson", item.NO || item.FID || item.id);
        // this.delCheckPerson(item.NO || item.FID || item.id);
        // this.$emit("update:organizationChoose", result);
        this.organizationChoose = result; //zk0601新增,某一项不为勾选状态则全选状态失效
      }
      this.modalSearchValue = "";
      this.modalSearchResult = []; //zk1228新增，添加完人员后查询结果置为空
      this.$forceUpdate();
    },
    modalSearchValueFn(success) {
      getUserListInfoSim({
        // name: this.modalSearchValue,
        name: this.newModalSearchValue,
        pageSize: this.searchSize,
        pageNumber: this.searchPage,
      }).then(success);
    },
    more_search(index) {
      // 新增组织机构搜索
      if (index == 99) {
        this.moreSearchShow = false;
        this.searchPage++;
        this.modalSearchValueFn((res) => {
          this.modalSearchResult = this.modalSearchResult.concat(res.data);
          this.moreSearchShow = true;
        });
      }
    },
    searchMemberEnter() {
      console.log(this.modalSearchValue, "搜索关键字");
      this.searchPage = 1;
      if (this.modalSearchValue != "") {
        //zk1228新增，enter键触发搜索
        getUserListInfoSim({
          name: this.modalSearchValue,
          pageSize: this.searchSize,
          pageNumber: this.searchPage,
        }).then((res) => {
          let result = res.data || [];
          //过滤已选ID
          result = result.filter(
            (item) => !this.checkPersonArray.some((ele) => ele.id === item.id)
          );
          //新增搜索群
          this.newGroupList = this.groupList.filter((item) =>
            item.name.match(this.modalSearchValue)
          );
          this.modalSearchResult = [...this.newGroupList, ...result];
          //查看更多的关键字
          this.newModalSearchValue = this.modalSearchValue;
          // this.modalSearchValue = ""; //zk1228新增
          this.issearching = true; //zk1228新增，搜索完成置为空，针对再次按enter时有搜索结果
        });
      } else {
        if (!this.issearching) {
          //zk1228新增
          this.modalSearchResult = [];
          this.searchResultShow = false;
        }
        this.issearching = false; //zk1228新增，搜索完成置为空，针对再次按enter时有搜索结果
      }
      if (this.modalSearchResult.length > 0 && !this.issearching) {
        //zk1228新增，&& !this.issearching
        // 分享群过滤掉已再群里的成员(组织架构)
        if (
          this.isShare &&
          this.shareChoosed.indexOf(
            this.modalSearchResult[0].ID ||
            this.modalSearchResult[0].id ||
            this.modalSearchResult[0].NO
          ) != -1
        ) {
          this.$Message.warning("人员已存在此群中");
        } else {
          this.setStruChoose(this.modalSearchResult[0]);
        }
      }
    },
    //组织架构树状点击打开|选择
    modalGetStru(item, index) {
      if (item.FID) {
        if (item.isChoose) return;
        this.modalCheckArray.index = item.FID;
        if (this.modalCheckArray.list2[this.modalCheckArray.index]) {
          this.modalCheckArray.navList.push({
            title: item.FID,
            value: item.LEABLE,
          });
          // 分享群过滤掉已再群里的成员(常用联系人)
          if (this.isShare) {
            this.modalCheckArray.list2[this.modalCheckArray.index] =
              this.modalCheckArray.list2[this.modalCheckArray.index].filter(
                (msg) =>
                  this.shareChoosed.indexOf(msg.ID || msg.id || msg.NO) == -1
              );
          }

          this.setSelectAll(
            this.modalCheckArray.list2[this.modalCheckArray.index]
          );
        } else {
          this.$startLoading(".modal_arr_box");
          //   this.$emit("update:organizationChoose", false);
          this.organizationChoose = false;
          console.warn("打开了");
          getGroup({
            fid: item.FID,
          })
            .then((res) => {
              this.$endLoading();
              let result = res.data;
              // 分享群过滤掉已再群里的成员(常用联系人)
              if (this.isShare) {
                result = result.filter(
                  (msg) =>
                    this.shareChoosed.indexOf(msg.ID || msg.id || msg.NO) == -1
                );
              }
              let count = 0; //zk0601计数选中数目,若数目等于result的长度,则修改全选状态
              for (let i = 0; i < this.checkPersonArray.length; i++) {
                for (let j = 0; j < result.length; j++) {
                  if (result[j].NO == this.checkPersonArray[i].id) {
                    this.$set(result[j], "isChoose", true);
                    count++; //zk0601新增
                  }
                }
              }
              if (count == result.length) this.organizationChoose = true;

              this.modalCheckArray.list2[item.FID] = result;
              this.modalCheckArray.navList.push({
                title: item.FID,
                value: item.LEABLE,
              });
              // 新增下载头像
              this.modalCheckArray.list2[item.FID].map((item) => {
                this.$emit("downLoadHeadPath", item);
                // this.downLoadHeadPath(item);
              });
              // 新增默认勾选已再群里的成员
              if (this.modalTitle == 4) {
                for (let value of this.modalCheckArray.list2[item.FID]) {
                  for (let temp of this.group_detail.users) {
                    if ((value.id || value.ID) == (temp.id || temp.ID)) {
                      this.$set(value, "isChoose", true);
                      break;
                    }
                  }
                }
              }
              this.$forceUpdate();
            })
            .catch((res) => {
              console.log(res);
            });
        }
      } else {
        this.setStruChoose(item, index);
      }
    },
    // 转发消息,添加参与人全选按钮隐藏
    selectAllShow(args) {
      if (this.modalTitle == 2 || this.modalTitle == 5) {
        let arr = args || [];
        for (let i in args) {
          if (args[i].NO) {
            return true;
          }
        }
        return false;
      } else {
        return true;
      }
    },
    modalFirstCancel() {
      this.$emit("modalFirstCancel");
    },
    //建群、发送广播、转发右侧父列表事件(点击常用联系人，最近联系人，组织架构，我的群组)
    setModalCheckArray(item, index) {
      console.log(item, index, 686);
      if (item && item.id && item.id == 7) {
        let items = {};
        items.id = "fileAssistant";
        items.isGroup = "0";
        items.name = "文件传输助手";
        items.userId = "fileAssistant";
        items.isChoose = false;
        this.setLastChoose(items, index);
        return;
      }
      let itemBool = item != null;
      this.$set(this.modalCheckArray, "show", itemBool);
      if (itemBool) {
        this.organizationChoose = true;

        let setArr = [
          { key: "show", value: true },
          { key: "title", value: item.title },
          { key: "id", value: item.id },
          { key: "index", value: "all" },
          {
            key: "navList",
            value: [
              {
                title: "all",
                value: "组织架构",
              },
            ],
          },
        ];
        setArr.forEach((i) => {
          this.$set(this.modalCheckArray, i.key, i.value);
        });
        // this.$emit("setModalCheckArrayKey");
        // this.$set(this.modalCheckArray, "show", true);
        // this.$set(this.modalCheckArray, "title", item.title);
        // this.$set(this.modalCheckArray, "id", item.id);
        // this.$set(this.modalCheckArray, "index", "all");
        // this.$set(this.modalCheckArray, "navList", [
        //   {
        //     title: "all",
        //     value: "组织架构",
        //   },
        // ]);
        if (item.id == 4) {
          // 分享群过滤掉已再群里的成员(常用联系人)
          if (this.isShare) {
            for (let temp of this.friendsGroup) {
              temp.USER = temp.USER.filter(
                (msg) => this.shareChoosed.indexOf(msg.ID || msg.id) == -1
              );
            }
          }
          let toBeChooseArr = this.friendsGroup[0].USER;
          for (let m = 0; m < toBeChooseArr.length; m++) {
            let index = this.checkPersonArray.findIndex((per) => {
              return per.id == toBeChooseArr[m].id;
            });
            if (index != -1) {
              this.$set(toBeChooseArr[m], "isChoose", true);
            }
          }
          Object.assign(this.modalCheckArray, {
            list: this.friendsGroup,
          });
        } else if (item.id == 3 && !this.modalCheckArray.list2) {
          Object.assign(this.modalCheckArray, {
            list2: {
              all: item.structureList,
            },
            index: "all",
          });
        } else if (item.id == 5 && !this.modalCheckArray.list3) {
          let res = this.sessionList;
          console.log(res, 766);
          // 分享群过滤掉已再群里的成员(最近联系人)
          if (this.isShare) {
            res = res.filter(
              (msg) =>
                this.shareChoosed.indexOf(msg.ID || msg.id) == -1 &&
                (msg.ID || msg.id != this.shareInfo.shareGroupId)
            );
          }
          res = JSON.parse(JSON.stringify(res));
          Object.assign(this.modalCheckArray, {
            list3: res,
          });
        } else if (item.id == 6 && !this.modalCheckArray.list4) {
          // 分享群过滤掉已再群里的成员(我的群组)
          if (this.isShare) {
            this.groupList = this.groupList.filter(
              (msg) => msg.id != this.shareInfo.shareGroupId
            );
          }
          Object.assign(this.modalCheckArray, {
            list4: this.groupList || [],
          });
        }
        if (item.id == 3) {
          this.setSelectAll(
            this.modalCheckArray.list2[this.modalCheckArray.index]
          );
        } else if (item.id == 4) {
          for (let k in this.modalCheckArray.list) {
            this.setSelectAll(this.modalCheckArray.list[k]);
          }
          // 新增下载头像
          this.modalCheckArray.list[0].USER.map((item) => {
            this.$emit("downLoadHeadPath", item);
            // this.downLoadHeadPath(item);
          });
          // 新增默认勾选已再群里的成员
          if (this.modalTitle == 4) {
            for (let value of this.modalCheckArray.list[0].USER) {
              for (let temp of this.group_detail.users) {
                if ((value.id || value.ID) == (temp.id || temp.ID)) {
                  this.$set(value, "isChoose", true);
                  break;
                }
              }
            }
          }
        } else if (item.id == 5) {
          this.setSelectAll(this.modalCheckArray.list3);
          // 新增下载头像
          this.modalCheckArray.list3.map((item) => {
            this.$emit("downLoadHeadPath", item);
            // this.downLoadHeadPath(item);
          });
        } else if (item.id == 6) {
          this.setSelectAll(this.modalCheckArray.list4);
        }
      }
    },
    //常用联系人选择成员
    setChoose(item, index) {
      this.setLastChoose(item, index);
    },
    //最近联系人选择成员
    setLastChoose(item, index) {
      console.log(item, 806);
      item.id = item.NO || item.FID || item.id || item.ID;
      item.name = item.LEABLE || item.name || item.NAME;
      // 新增添加群成员 已再群里的成员禁止切换选中状态
      if (this.modalTitle == 4) {
        let arr =
          this.group_detail.users.filter(
            (value) => item.id == (value.id || value.ID)
          ) || [];
        if (arr.length > 0) return;
      }
      let res = !item.isChoose;
      this.$set(item, "isChoose", res);
      if (res) {
        this.$emit("checkPersonArrayPush", item, 1);
        // this.checkPersonArray.push(item);
        let allArr = [];
        for (let i = 0; i < this.checkPersonArray.length; i++) {
          let flag = true;
          for (let j = 0; j < allArr.length; j++) {
            if (
              (this.checkPersonArray[i].id || this.checkPersonArray[i].ID) ==
              (allArr[j].id || allArr[j].ID)
            ) {
              flag = false;
            }
          }
          if (flag) {
            allArr.push(this.checkPersonArray[i]);
          }
        }
        this.$emit("checkPersonArrayPush", allArr, 2);
        // this.checkPersonArray = allArr;
      } else {
        this.$emit("delCheckPerson", item.id);
        // this.delCheckPerson(item.id);
      }
    },

    //建群，zk注释，人员选定之后点击确认触发
    async determine() {
      console.log(
        "this.modalCheckArray",
        this.modalTitle,
        this.modalFirstList,
        this.modalCheckArray
      );
      this.$emit("update:modalCheckArray", {});
      //   this.modalCheckArray = {};
      if (this.personalStatus == 4) {
        this.$Message.warning("离线状态无进行该操作");
        return;
      }
      let arr = [];
      let initid = this.$func.uuid();

      if (this.modalTitle == 0) {
        if (this.modalNameValue.length > 15) {
          this.$Message.warning("群名称超过最大长度(15位)", 3);
          return;
        }
        if (this.modalNameValue.length < 1) {
          this.$Message.warning("群名称不能为空，请输入群名", 3);
          return;
        }
        for (let i = 0, len = this.checkPersonArray.length; i < len; i++) {
          if (this.checkPersonArray[i].userId == "fileAssistant") {
            this.$Message.warning("群聊无法添加文件传输助手");
            return;
          }
          arr.push({
            type: this.checkPersonArray[i].FID ? "1" : "0",
            value: this.checkPersonArray[i].id,
          });
        }
        let groupName =
          this.modalNameValue.trim() == ""
            ? "群聊"
            : this.modalNameValue.trim();
        if (arr.length > 0) {
          this.$emit("update:addUserDisabled", true);
          //   this.addUserDisabled = true;
          addGroup({
            userid: this.myInfo.id,
            name: groupName,
            introduce: "",
            members: JSON.stringify(arr),
          })
            .then((res) => {
              this.$emit("update:addUserDisabled", false);
              //   this.addUserDisabled = false;
              if (res.result == 200) {
                this.modalNameValue = "";
                this.modalSearchValue = "";
                this.$emit("resetModalFirst");
                // this.resetModalFirst();

                // this.resetContacts();
                this.$emit("update:modalFirst", false);
                // this.modalFirst = false;
                this.$emit("getGroupUser");
                // this.getGroupUser();
                this.$Message.success("创建成功");
              } else if (res.result == 500) {
                // 群聊人数多于千人或少于2人
                this.$Message.warning(res.msg);
              } else if (res.result == 2) {
                this.$Message.warning("无权限");
              }
            })
            .catch((error) => {
              this.$emit("update:addUserDisabled", false);
              //   this.addUserDisabled = false;
            });
        } else {
          this.$Message.destroy();
          this.$Message.warning({
            content: "至少邀请1位联系人加入群",
            duration: 1,
          });
        }
      } else if (this.modalTitle == 1) {
        for (let i in this.checkPersonArray) {
          arr.push({
            type: this.checkPersonArray[i].FID ? "1" : "0",
            id: this.checkPersonArray[i].id,
            value: this.checkPersonArray[i].id,
            name: this.checkPersonArray[i].name,
          });
        }
        this.$emit("update:broadSendList", arr);
        // this.broadSendList = arr;
        this.$emit("update:modalFirst", false);
        // this.modalFirst = false;
        this.$emit("resetContacts");
        // this.resetContacts();
      } else if (this.modalTitle == 2) {
        //zk注释，转发确定
        this.$emit("update:isMultiSelect", false);
        // this.isMultiSelect = false;
        //转发本地文件选项 czx

        if (this.isToForwardingLocal) {
          this.$emit("update:isToForwardingLocal", false);
          this.$emit("update:chatChooseList", [this.toForwardingLocal]);
          // 2022/6/8 zc修改 实现转发本地文件，文件内容替换
          this.chatChooseList = [this.toForwardingLocal];
          //   this.chatChooseList = [this.toForwardingLocal];
          //   this.isToForwardingLocal = false;
        }
        const checkPersonArray = JSON.parse(
          JSON.stringify(this.checkPersonArray)
        );
        const chatChooseList = JSON.parse(JSON.stringify(this.chatChooseList));
        this.$emit("update:chatChooseList", []);
        // this.chatChooseList = [];
        let isTrue = this.toInfo.isGroup == "1";
        // console.log(checkPersonArray, chatChooseList, 996);
        this.chuanshu = []
        for (let j = 0; j < checkPersonArray.length; j++) {
          for (let i = 0; i < chatChooseList.length; i++) {
            console.log(checkPersonArray[j].name, chatChooseList[i].type, 997);
            this.chuanshu.push(0)
            if (
              checkPersonArray[j].name == "文件传输助手" &&
              chatChooseList[i].type == "article"
            ) {
              this.chuanshu.push(1)
              this.$Message.error("文章无法转发文件传输助手");
              continue;
            }
            if (!checkPersonArray[j].headPath) {
              //zk新增，没有头像就下载
              this.$emit("downLoadHeadPath", checkPersonArray[j]);
              //   this.downLoadHeadPath(checkPersonArray[j]);
            }
            console.log(chatChooseList, "987");
            setTimeout(() => {
              checkPersonArray[j].isGroup =
                checkPersonArray[j].isGroup == "1" ? "1" : "0";
              let initKey = this.$func.uuid();
              if (chatChooseList[i].type == "image") {
                let suffix = chatChooseList[i].value
                  .toLowerCase()
                  .split(".")
                  .splice(-1);
                /**
                 * 图片转发
                 * @param {Object} checkPersonArray[j] 转发人员的所有信息
                 * @param {String} initKey UUID
                 * @param {String} id 下载ID
                 * @param {String} size 图片大小（解决三端字段不统一的问题）
                 * @param {String} name 图片名称
                 * @param {String} duration 图片大小（解决三端字段不统一的问题）
                 * @param {String} gender 发送人的性别
                 * @param {String} head 发送人的头像ID
                 */
                this.$wsSendMsg(
                  checkPersonArray[j],
                  initKey,
                  "image",
                  {
                    id: chatChooseList[i].DownLoadId,
                    size: chatChooseList[i].duration,
                    name:
                      this.myInfo.id +
                      new Date().getTime() +
                      ("." + suffix[0] || ".png"),
                    duration: 32,
                    gender: this.myInfo.gender || "1",
                    head: this.myInfo.head || "",
                  },
                  this.ws
                );
              } else if (chatChooseList[i].type == "file") {
                console.log(chatChooseList[i], "file");
                if (chatChooseList[i].uploading) {
                  this.$Message.success("文件上传中,请稍后转发");
                  return;
                }
                //先存本地
                let table =
                  checkPersonArray[j].isGroup == "0"
                    ? this.sqlTable.privateList
                    : this.sqlTable.messageList;
                // 2022/6/8 zc修改 如果转发文件为已下载文件，转发后isDownLoad为该文件存储路径，无需下载即可打开
                let time = new Date().getTime();
                tools.operationalDatabase(
                  `REPLACE INTO ${table}(name,receiveId,sendId,type,value,time,messageId,isRead,isSuccessSend,isDownLoad,DownLoadId,duration) VALUES(
                  '${this.myInfo.name}','${checkPersonArray[j].id}','${this.myInfo.id
                  }','file',
                  '${chatChooseList[i].value
                  }','${time}','${initKey}','1','1','${chatChooseList[i].isDownLoad == "1"
                    ? chatChooseList[i].address
                    : "0"
                  }',
                  '${chatChooseList[i].DownLoadId}','${chatChooseList[i].duration
                  }');`
                );
                this.$wsSendMsg(
                  checkPersonArray[j],
                  initKey,
                  "file",
                  {
                    id: chatChooseList[i].DownLoadId,
                    size: chatChooseList[i].duration,
                    name: chatChooseList[i].value,
                    duration: chatChooseList[i].duration,
                    isDownLoad:
                      chatChooseList[i].isDownLoad == "1"
                        ? chatChooseList[i].address
                        : "0",
                    DownLoadId: chatChooseList[i].DownLoadId,
                    gender: this.myInfo.gender || "1",
                    head: this.myInfo.head || "",
                  },
                  this.ws
                );
                // console.log('转发人员：',checkPersonArray[j],'myInfo:',this.myInfo)
                //存本地后刷新左侧会话列表
                this.$emit(
                  "updateSessionChat",
                  this.myInfo.id,
                  checkPersonArray[j].id,
                  this.myInfo.name,
                  checkPersonArray[j].name,
                  chatChooseList[i].value,
                  time,
                  checkPersonArray[j].isGroup,
                  initKey,
                  "file",
                  chatChooseList[i].duration,
                  chatChooseList[i].isDownLoad == "1"
                    ? chatChooseList[i].address
                    : "0",
                  chatChooseList[i].DownLoadId,
                  "",
                  "",
                  checkPersonArray[j].gender || "1",
                  checkPersonArray[j].head
                );
                // this.updateSessionChat(
                //   this.myInfo.id,
                //   checkPersonArray[j].id,
                //   this.myInfo.name,
                //   checkPersonArray[j].name,
                //   chatChooseList[i].value,
                //   time,
                //   checkPersonArray[j].isGroup,
                //   initKey,
                //   "file",
                //   chatChooseList[i].duration,
                //   chatChooseList[i].isDownLoad,
                //   chatChooseList[i].DownLoadId,
                //   "",
                //   "",
                //   checkPersonArray[j].gender || "1",
                //   checkPersonArray[j].head
                // );
              } else if (chatChooseList[i].type == "GPS") {
                let value = JSON.parse(chatChooseList[i].value);
                value = eval("(" + value + ")");
                value = JSON.stringify(value);
                this.$wsSendMsg(
                  checkPersonArray[j],
                  initKey,
                  chatChooseList[i].type,
                  {
                    text: value,
                    gender: this.myInfo.gender || "1",
                    head: this.myInfo.head || "",
                  },
                  this.ws
                );
              } else if (chatChooseList[i].type == "video") {
                this.$wsSendMsg(
                  checkPersonArray[j],
                  initKey,
                  "video",
                  {
                    id: chatChooseList[i].DownLoadId,
                    size: chatChooseList[i].duration,
                    name: chatChooseList[i].value,
                    duration: chatChooseList[i].duration,
                    url: chatChooseList[i].DownLoadId,
                    DownLoadId: chatChooseList[i].DownLoadId,
                    gender: this.myInfo.gender || "1",
                    head: this.myInfo.head || "",
                    text: chatChooseList[i].value,
                  },
                  this.ws
                );
              } else if (chatChooseList[i].type == "text") {
                //文字转发
                let str;
                if (isTrue) {
                  str = `${isTrue
                    ? this.sqlTable.messageList
                    : this.sqlTable.privateList
                    } WHERE messageId='${chatChooseList[i].messageId}'`;
                } else {
                  str = `${isTrue
                    ? this.sqlTable.messageList
                    : this.sqlTable.privateList
                    } WHERE messageId='${chatChooseList[i].messageId}'`;
                }
                let res = tools.operationalDatabase(
                  `SELECT * FROM  ${str} ORDER BY time DESC;`,
                  1
                );
                if (res.list.length > 0) {
                  chatChooseList[i].value = res.list[0].value;
                }
                //this.storageSqlSendText(chatChooseList[i])
                console.log("发送的对象", checkPersonArray[j]);
                this.$wsSendMsg(
                  checkPersonArray[j],
                  initKey,
                  chatChooseList[i].type,
                  {
                    text: tools.textMsg(chatChooseList[i].value),
                    gender: this.myInfo.gender || "1",
                    head: this.myInfo.head || "",
                  },
                  this.ws
                );
              } else if (chatChooseList[i].type == "article") {
                let value;
                let userID = [
                  {
                    type: checkPersonArray[j].FID ? "1" : "0", // 1 部门 0 人
                    value:
                      checkPersonArray[j].FID ||
                      checkPersonArray[j].id ||
                      checkPersonArray[j].ID,
                  },
                ];
                let initid = this.$func.uuid();
                // 2022/7/26 修改 普通转发与收藏中转发数据结构不同判断区分
                if (chatChooseList[i].value) {
                  value = JSON.parse(chatChooseList[i].value) || {};
                  article_axios({
                    userId: this.myInfo.id,
                    members: JSON.stringify(userID),
                    articleId: initid,
                    article: JSON.stringify({
                      articleLink: value.url,
                      updateDate: new Date().getTime(),
                      describe: value.describe,
                      id: initid,
                      title: value.title,
                      picture: value.imgUrl || "",
                    }),
                  })
                    .then((res) => {
                      if (res.resp_code == 0) {
                        this.$Message.success(res.resp_msg);
                      } else {
                        {
                          this.$Message.warning(res.resp_msg);
                        }
                      }
                    })
                    .catch((err) => {
                      this.$Message.warning(err.resp_msg);
                    });
                } else {
                  article_axios({
                    userId: this.myInfo.id,
                    members: JSON.stringify(userID),
                    article: JSON.stringify({
                      articleLink: chatChooseList[i].url,
                      updateDate: new Date().getTime(),
                      describe: chatChooseList[i].describe,
                      id: initid,
                      title: chatChooseList[i].title,
                      picture: chatChooseList[i].picture || "",
                    }),
                  })
                    .then((res) => {
                      if (res.resp_code == 0) {
                        this.$Message.success(res.resp_msg);
                      } else {
                        {
                          this.$Message.warning(res.resp_msg);
                        }
                      }
                    })
                    .catch((err) => {
                      this.$Message.warning(err.resp_msg);
                    });
                }
              }
              //转发留言
              if (this.forwardMsg && i == chatChooseList.length - 1) {
                this.$wsSendMsg(
                  checkPersonArray[j],
                  this.$func.uuid(),
                  "text",
                  {
                    text: this.forwardMsg,
                    gender: this.myInfo.gender || "1",
                    head: this.myInfo.head || "",
                  },
                  this.ws
                );
                // 2022/7/12 转发完置空
                this.forwardMsg = "";
              }
            }, i * j * 200);
          }
        }
        this.onceCheckArray = checkPersonArray; //zk新增，当前选中人员存入

        this.$emit("update:modalFirst", false);
      if (this.chuanshu.includes(1)) {
        this.$Message.error("文章无法转发文件传输助手");
      }else {
        
        this.$Message.success("转发成功");
      }
        // this.modalFirst = false;
        this.$emit("resetModalFirst");
        // this.resetModalFirst();
      } else if (this.modalTitle == 3) {
        console.log("转发文件内容", this.forwardingList);
        console.log("转发目标", this.checkPersonArray);
        let forwardingList = this.forwardingList || [];
        let checkPersonArray = this.checkPersonArray || [];
        for (let i = 0; i < forwardingList.length; i++) {
          for (let j in checkPersonArray) {
            setTimeout(() => {
              let initKey = this.$func.uuid();
              checkPersonArray[j].isGroup =
                checkPersonArray[j].isGroup == "1" ? "1" : "0";
              this.$wsSendMsg(
                checkPersonArray[j],
                initKey,
                "file",
                {
                  id: forwardingList[i].DownLoadId,
                  size: forwardingList[i].duration,
                  name: forwardingList[i].value,
                  duration: forwardingList[i].duration,
                  isDownLoad: "0",
                  DownLoadId: forwardingList[i].DownLoadId,
                  gender: checkPersonArray[j].gender || "1",
                  head: checkPersonArray[j].head || "",
                },
                this.ws
              );
              if (
                i == forwardingList.length - 1 &&
                j == checkPersonArray.length - 1
              ) {
                this.$Message.info("发送完成!");
              }
            }, 1000 * (i + j));
          }
          if (i == forwardingList.length - 1) {
            this.$emit("update:modalFirst", false);
            // this.modalFirst = false;
            this.isResetFiles = true;
          }
        }
        this.$emit("resetModalFirst");
        // this.resetModalFirst();
      } else if (this.modalTitle == 4) {
        for (let i = 0, len = this.checkPersonArray.length; i < len; i++) {
          arr.push({
            type: this.checkPersonArray[i].FID ? "1" : "0",
            value: this.checkPersonArray[i].id,
          });
        }
        // 2022/5/17 zc修改，确定完后重置，如果放在请求内会无效
        this.checkPersonArray = [];
        this.$emit("resetModalFirst");
        if (arr.length > 0) {
          addGroupMembers({
            userid: this.myInfo.id,
            groupid: this.toInfo.id,
            members: JSON.stringify(arr),
          }).then((res) => {
            // 请求貌似不会返回，变成socket推送了
            if (res.result == 200) {
              this.$emit("update:modalFirst", false);
              //   this.modalFirst = false;
              this.getGroupAndUsers(this.toInfo.id);
              this.$Message.success("添加成员成功");
              this.$emit("resetModalFirst");
              //   this.resetModalFirst();
            } else {
              this.$Message.success("添加失败");
            }
          });
        } else {
          this.$Message.destroy();
          this.$Message.warning({
            content: "至少邀请一位联系人加入群",
            duration: 1,
          });
        }
      } else if (this.modalTitle == 5) {
        let arr = [{ id: this.myInfo.id, name: this.myInfo.name }];
        for (let i in this.checkPersonArray) {
          arr.push({
            id: this.checkPersonArray[i].id,
            name: this.checkPersonArray[i].name,
          });
        }
        this.$emit("update:participant", arr);
        // this.participant = arr;
        this.$emit("update:modalFirst", false);
        // this.modalFirst = false;
      } else if (this.modalTitle == 6 || this.modalTitle == 7) {
        //zk1215标识，群分享
        let fidArr = this.checkPersonArray.filter((item) => item.FID);
        if (fidArr.length > 0) {
          let personArr = this.checkPersonArray.filter((item) => !item.FID);
          let fidString = [];
          fidArr.map((item) => {
            fidString.push({
              type: 1,
              value: item.FID,
            });
          });
          getGroupPeople(fidString)
            .then((res) => {
              if (res.result === 200) {
                let newArr = res.data || [];
                this.sendShareMessage([...personArr, ...newArr], initid);
              }
            })
            .catch((res) => {
              console.log(res, "err=>");
            });
        } else this.sendShareMessage(this.checkPersonArray, initid);
      } else if (this.modalTitle == 8) {
        console.log(this.checkPersonArray);
        let articleSendList = this.checkPersonArray;
        // 2022/5/12 zc新增 更新文章发送人列表
        this.$emit("update:articleSendList", articleSendList);
        this.$emit("update:modalFirst", false);
        this.checkPersonArray = [];
        this.$emit("resetModalFirst");
        // this.modalFirst = false;
        // this.$emit("resetContacts");
      } else if (this.modalTitle == 9) {
        console.log(this.screenFlag); //zk0518修改,screenFlag是个对象,取其属性flag做判断条件
        if (this.screenFlag.flag == 0) {
          // 同屏邀请
          // this.screenPersonList = this.checkPersonArray;
          // this.screenPersonList = [...this.checkPersonArray];//zk0531修改,深度拷贝数组,确保监听screenPersonList正常触发(点击确定才触发)
          let arr = await this.getAllPerson(this.checkPersonArray);
          console.log(arr, 1370);
          let uniqueArr = this.$utilJs.getUniqueItem(arr);
          // this.screenPersonList = [...uniqueArr];
          this.$emit("update:screenPersonList", [...uniqueArr]);
        } else if (this.screenFlag.flag == 1) {
          // 分享同屏
          let checkPersonArraySave = this.checkPersonArray;
          for (let i in checkPersonArraySave) {
            setTimeout(() => {
              console.log("分享同屏", i, checkPersonArraySave[i]);
              this.$wsSendMsg(
                checkPersonArraySave[i],
                this.$func.uuid(),
                "screen",
                {
                  // text: "共享屏幕",
                  text: this.screenFlag.room
                    ? JSON.stringify(this.screenFlag.room)
                    : "", //zk0601修改,分享同屏无法进入问题
                  gender: this.myInfo.gender || "1",
                  head: this.myInfo.headImage || "",
                },
                this.ws
              );
            }, 200 * i);
          }
        } else if (this.screenFlag.flag == 2) {
          // 在线、离线人员旁边的邀请
          console.log(this.checkPersonArray, "开启同屏后邀请人");
          this.isUpdateUser = true; //zk0531新增,针对同屏开启后邀请人无效
          // this.screenPersonList = this.checkPersonArray;
          // this.screenPersonList = [...this.checkPersonArray]//zk0531修改,深度拷贝数组,确保监听screenPersonList正常触发

          //zk0531修改,对同屏后邀请和同屏开始前的邀请做去重
          let oldList = [...this.screenPersonList];
          let oldIdList = [];
          for (let i in oldList) {
            oldIdList.push(oldList[i].id);
          }
          let newList = [...this.checkPersonArray];
          let tempList = oldList.concat(
            newList.filter((item) => {
              return oldIdList.indexOf(item.id) == -1;
            })
          );
          // this.screenPersonList = tempList
          console.log("在线、离线人员旁边的邀请", tempList);
          let arr = await this.getAllPerson(tempList);
          console.log(arr, 1416);
          let uniqueArr = this.$utilJs.getUniqueItem(arr);
          // this.screenPersonList = [...uniqueArr];
          this.$emit("update:screenPersonList", [...uniqueArr]);
        }
        this.$emit("update:modalFirst", false);
        // this.modalFirst = false;
        this.$emit("resetModalFirst");
        // this.resetModalFirst();
      }
    },
    async getAllPerson(personArr) {
      // zk0531新增,组织建构勾选去重,并获取部门里的成员,返回值为全部成员的数组,personArr:原始数组,里面有人,有部门
      this.$startLoading(".ivu-modal-content-drag");
      let arr = [...personArr];
      let tempArr = [];
      for (let i in arr) {
        if (arr[i].FID) {
          //部门
          let id = arr[i].id || arr[i].FID;
          let res = await this.$axios.post(
            `${this.$store.state.url}user/getUsersByDeptId.do`,
            { deptId: id }
          );
          if (res.data.result == 200) {
            //获取数据不为空
            tempArr = tempArr.concat(res.data.data);
          }
        } else {
          //人
          tempArr.push(arr[i]);
        }
      }
      this.$endLoading();

      console.log(tempArr, 1449);
      return tempArr;
    },

    //群分享/文件分享 发送消息部分
    sendShareMessage(arr, uuid) {
      if (this.modalTitle == 6) {
        //zk1215标识，群分享发送中
        // 分享群过滤掉已再群里的成员(组织架构)
        if (this.isShare) {
          arr = arr.filter(
            (item) =>
              this.shareChoosed.indexOf(item.ID || item.id || item.NO) == -1
          );
        }
        for (let i in arr) {
          arr[i].isGroup = arr[i].isGroup == "1" ? "1" : "0";
          this.$wsSendMsg(
            arr[i],
            uuid,
            "shareGroup",
            {
              text: JSON.stringify(this.shareInfo),
              gender: this.myInfo.gender || "1",
              head: this.myInfo.head || "",
            },
            this.ws
          );
          if (i == arr.length - 1) this.$emit("update:modalFirst", false);
        }
      } else if (this.modalTitle == 7) {
        console.log(this.shareFileArr, "进入分享文件");
        // 分享文件
        let AllImgExt = "jpg|jpeg|bmp|png|swf|gif|tiff";
        for (let i = 0; i < arr.length; i++) {
          for (let j = 0; j < this.shareFileArr.length; j++) {
            let initid = this.$func.uuid(); // 解决同一个key数据库只存一条的问题
            // let type = AllImgExt.indexOf((this.shareFileArr[j].sfiType.split('/')[1]).toLowerCase()) != -1 ? 'image' : 'file';
            this.$wsSendMsg(
              {
                id: arr[i].ID || arr[i].id,
                name: arr[i].NAME || arr[i].name,
                isGroup: "0",
              },
              initid,
              "file",
              {
                id: this.shareFileArr[j].sfiActualPath,
                size: this.shareFileArr[j].sfiSize,
                name: this.shareFileArr[j].sfiName,
                duration: this.shareFileArr[j].sfiSize,
                isDownLoad: "0",
                DownLoadId: this.shareFileArr[j].sfiActualPath,
                gender: this.myInfo.gender,
                head: this.myInfo.head,
                isSharedFile: "1",
              },
              this.ws
            );
          }
        }

        // this.$Message.success("分享成功");
      }
      this.$emit("update:modalFirst", false);
      //   this.modalFirst = false;
      this.$emit("resetModalFirst");
      //   this.resetModalFirst();
      // this.$Message.success('分享成功')

      let ifream1 = window.frames[0];
      let ifream = window.frames["iframe"].contentWindow;
      console.log(ifream1, ifream, 1582);
      window.addEventListener("message", (e) => {
        console.log(e, "ifream  传来的消息");
      });
                                   
      let params = {
        code: 200,
        msg: "分享成功",
        type: "share",
      };
      // ifream.postMessage(params, "http://172.16.47.240:8081");
      // ifream.postMessage(params, this.$store.state.postmessageShareUrl);
      ifream.postMessage(params, '*');

    //  let res =  this.$shell1("ShareFileSuccess",['0']);

    //  console.log(res,1600);
    },

    

    // checkPersonDelete(a, b) {
    //   this.$emit("checkPersonDelete", a, b);
    // },
   
  },
  created() {
    // 2022/7/25 新增 创建转发框时获取一次群组信息
    this.$emit("getGroupUser");
    
  },
};
</script>
<style  lang="less" scoped>
// .modal_head {
//   background-color: #222;
// }
// .close_btn {
//   color: #495060;
//   border: 1px solid #ddd;
// }
</style>
